<div class="wrap">
    <h2>HTML5 AV Settings</h2>
    <form method="post" action="options.php">
        <p><label for="html5av_manager_position" >Video/Audio Position in each post:</label>
            <select id="html5av_manager_position" name="html5av_manager_position" >
                <?php foreach ($positions as $value => $selected) : ?>
                    <option value="<?php echo $value ?>"
                            <?php echo $selected ?> ><?php echo $value ?></option>
                        <?php endforeach; ?>
            </select>
            <br />
            'manual' is most flexible but requires theme modification
            (&lt;?php do_action('get_htmlav_from_post', get_the_ID()); ?&gt;) or
            use of shortcode ([html5av id='1' view='false']).</p>

        <p><label for="html5av_manager_video_view" >Default View for Video:</label>
            <select id="html5av_manager_video_view" name="html5av_manager_video_view" >
                <?php foreach ($videoViews as $value => $selected) : ?>
                    <option value="<?php echo $value ?>"
                            <?php echo $selected ?> ><?php echo $value ?></option>
                        <?php endforeach; ?>
            </select></p>

        <p><label for="html5av_manager_audio_view" >Default View for Audio:</label>
            <select id="html5av_manager_audio_view" name="html5av_manager_audio_view" >
                <?php foreach ($audioViews as $value => $selected) : ?>
                    <option value="<?php echo $value ?>"
                            <?php echo $selected ?> ><?php echo $value ?></option>
                        <?php endforeach; ?>
            </select></p>
        <?php settings_fields('html5av_manager_settting'); ?>

        <p class="submit" >
            <input type="submit" class="button-primary" value="Save Changes" />
        </p>
    </form>

    <form id="html5av_manager_file_setting_form">
        <label for="html5av_manager_file_setting"><h3>setting.php</h3></label>
        Please don't touch this, unless you are an advanced user or a nerd.
        <span id="template">
            <textarea id="html5av_manager_file_setting" cols="50" rows="10"
                      style="width: 100%; height: 25em;"
                      ><?php echo $file_setting ?></textarea>
        </span>
        <p class="submit" >
            <input type="submit" class="button-primary" value="Save Changes to setting.php" />
            <span id="html5av_manager_setting_saved" style="color: green"></span>
        </p>
    </form>
</div>

<script type="text/javascript" >
    var html5av_api = '<?php echo html5av_manager::getApiURL(); ?>';
    
    jQuery(function ($) {
        $('#html5av_manager_file_setting_form').submit(function() {
            var setting_file = $('#html5av_manager_file_setting').val();
            var post = {
                action: 'html5av_manager',
                node:'setting_file_submit',
                setting_file:setting_file
            };
                
            $.post(ajaxurl, post, function(output) {
                $('#html5av_manager_setting_saved').empty();
                $('#html5av_manager_setting_saved').show();
                $('#html5av_manager_setting_saved').text(output);
                $('#html5av_manager_setting_saved').fadeOut(5000);
            })
            
            return false;
        });
    });
</script>